<template>
    <section>
        <!--获取权限按钮-->
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
            <el-form :inline="true" @submit.prevent>
            <el-form-item>
                <el-input v-model="searchVal" placeholder="请输入内容"></el-input>
            </el-form-item>
            <!-- 这个就是当前页面内，所有的btn列表 -->
            <el-form-item>
                <!-- 这里触发点击事件 -->
                <el-button type="primary" @click="getRoles">查询</el-button>
                <el-button type="primary" @click="handleAdd">新增</el-button>
                <el-button type="primary" @click="handleEdit">编辑</el-button>
                <el-button type="danger" @click="handleDel">删除</el-button>
            </el-form-item>
            </el-form>
        </el-col>

        <el-table :data="roles" style="width: 100%">
            <el-table-column type="selection" width="30" /> 
            <el-table-column fixed type="index" width="40" /> 
            <el-table-column fixed prop="name" label="角色名" width="150" sortable />
            <el-table-column prop="name" label="权限范围" width="120" sortable />
            <el-table-column prop="description" label="说明" width="120" sortable />
            <el-table-column prop="createTime" label="创建时间" width="320" sortable />
            <el-table-column prop="enabled" label="状态" width="1000" sortable />
        </el-table>
    </section>
</template>

<script>
//import {ref} from 'vue'
import {getRoleList} from '@/api/api';

export default{
    setup(){
        //const searchVal = ref('');
        //const roles = ref([]);
    },
    data(){
        return{
            searchVal:'',
            roles:[]
        }
    },
    methods:{
        getRoles(){
            console.log('角色查询',this.searchVal)
        },
        handleAdd(){
            console.log('新增角色')
        },
        handleEdit(){
            console.log('编辑角色')
        },
        handleDel(){
            console.log('删除角色')
        },
        getRolesPage(){
            let para = {
                page : 1,
                key:this.searchVal
            }
            getRoleList(para).then((res)=>{
                //console.log(res.response)
                this.roles = res.response.data;
            })
        }
    },
    mounted(){
        this.getRolesPage();
    }
}



</script>